package com.liwenfeng;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.liwenfeng.domain.Account;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;

@SpringBootApplication
@MapperScan
public class MyBatisPlusTest {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(MyBatisPlusTest.class,args);
        AccountMapper accountMapper = context.getBean(AccountMapper.class);
        test(accountMapper,List.of("张三","王五"));
    }

    static void test(AccountMapper mapper, List<String> list){
        LambdaQueryWrapper<Account> query = new LambdaQueryWrapper<>();
        query.in(!list.isEmpty(),Account::getName,list);
        for (Account account : mapper.selectList(query)) {
            System.out.println(account);
        }
    }
}
